function compose(arr) {
  return (...arg) => {
    let data = arr.pop()(...arg);
    for (let i = arr.length - 1; i >= 0; i--) {
      data = arr[i](data);
    }
    return data;
  };
}

console.log(
  compose([
    (item) => {
      console.log(item);
      return item + 1;
    },
    (item) => {
      console.log(item);
      return item + 2;
    },
    (item) => {
      console.log(item);
      return item + 3;
    },
  ])(0)
);
